home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_02_1984_Transactor_Publishing.d64
/
cia timer demo
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
4KB
|
150 lines
1000 rem"[211]=save"0:6timer b show",8
1010 [143]"atn_1150
1020 rem----------------------------
1030 rem 6526/cia timer-b liz deal
1040 rem----------------------------
1050 tm=08:mc=832:b0=176
1052 ifpeek(mc)*peek(mc+1)<>76*75thenforj=832to1022:readv:pokej,v:nextj
1060 i$="":print"[155][147]";
1070 print" <cr;ctrl;wipe+cr> timeout: :intbit "
1080 input" do test 1 2 1[157][157][157]";i$
1090 pokeb0,tm
1100 onasc(i$+"0")-48goto1120,1130
1110 end
1120 sysmc:goto1060
1130 sysmc+6:sysmc+3:goto1060
1135 rem source code below can be omitted
1137 rem data from 5000 on must be entered
1140 rem----------------------------
1150 sys700 ;pal
1160 .opt oo
1170 *=$0340 ;save to $3ff
1180 ;
1190 jmp test1
1200 jmp test2
1210 jmp nmisw
1220 here .word mynmi
1230 ;
1240 p =17*40+28 ;for screen
1250 cia2 =$dd00 ;non-kb cia
1260 ta2 =cia2+4 ;timer a
1270 tb2 =cia2+6 ;timer b
1280 cra2 =cia2+$e ;ctrl reg a
1290 crb2 =cia2+$f ;ctrl reg b
1300 icr2 =cia2+$d ;int ctrl+flags
1310 cia1 =$dc00 ;the other cia
1320 prb1 =cia1+1 ;stop key here
1330 col =$d800
1340 mask1 =%00000010
1350 mask2 =%10000010
1360 ctrlky =$fb
1370 anynmi =$318
1380 nornmi =$fe47
1390 inex =$febc
1400 val =$b0 ;(NULL)es into tb2
1410 once =val+1
1420 to =col+p ;to always moves
1430 in =col+p+1 ;in,noise when
1440 noise =$d418 ;timerb sets flg
1450 ;---------------------------------
1460 ;tb sometimes fails to set a flag
1470 ;show#1 - not asking for interrupt
1480 ;---------------------------------
1490 test1 =*
1500 lda icr2
1510 sei:lda #%01111111:jsr setup
1520 lda #mask1
1530 wait =*
1540 jsr teststop:beq quit
1550 ; watch timer b reload
1560 jsr watch
1570 ; check timeout flag,loop if 0
1580 bit icr2:beq wait
1590 ; flag worked this time
1600 jsr click:beq wait ;always more
1610 ; back to basic
1620 quit cli:rts
1630 ;---------------------------------
1640 ;show#2 - asking for an interrupt
1650 ;seems to work most of the time
1660 ;=====(can't prove non-failure!)
1670 ;---------------------------------
1680 nmisw =*
1690 ; clr flags in hope of surviving
1700 ; what follows
1710 lda icr2:lda #%01111111:sta icr2
1720 ; revector nmi stuff to here
1730 ; this can kill you
1740 lda here:ldx here+1:jsr setvec
1750 ; now tell the icr & clocks
1760 lda #mask2:jsr setup:rts
1770 ;
1780 mynmi =*
1790 pha:lda icr2:and #2:beq myi2
1800 txa:pha:tya:pha:jsr click:jmp inex
1810 myi2 pla:jmp nornmi
1820 ;
1830 test2 =*
1840 ; nothing better to do loop
1850 jsr watch:jsr teststop:bne test2
1860 ; set things back to normal
1870 lda #0:sta icr2
1880 lda #<nornmi:ldx #>nornmi
1890 setvec =*
1900 sta anynmi:stx anynmi+1
1910 rts
1920 ;
1930 teststop =*
1940 ldx prb1:cpx #ctrlky:rts
1950 ;
1960 watch =*
1970 ; watches timer b reload
1980 ; ignore quick reading results
1990 ldx tb2:cpx val:bcc watch9
2000 cpx once:beq watch9
2010 inc to ;displ timeout
2020 watch9 stx once:rts
2030 ;
2040 click =* ; & displ flag set
2050 inc in:ldx #8:stx noise
2060 sig1 dex:bne sig1
2070 stx noise:rts ;z=1
2080 ;
2090 setup =*
2100 sta icr2:sta to:sta in:inc in
2110 ; init clocks (val*ta)whatevers
2120 ldx #$ff:stx ta2:stx ta2+1
2130 inx:stx tb2+1:stx once
2140 ldx val:stx tb2
2150 ; force load time,tb counts ta
2160 ; timeouts, cont mode,clocks run
2170 lda #%00010001:sta cra2
2180 lda #%01010001:sta crb2
2190 rts
2200 .end
2210 end
5000 data 76,75,3,76,151,3,76,106
5001 data 3,129,3,173,13,221,120,169
5002 data 127,32,213,3,169,2,32,175
5003 data 3,240,13,32,181,3,44,13
5004 data 221,240,243,32,198,3,240,238
5005 data 88,96,173,13,221,169,127,141
5006 data 13,221,173,73,3,174,74,3
5007 data 32,168,3,169,130,32,213,3
5008 data 96,72,173,13,221,41,2,240
5009 data 10,138,72,152,72,32,198,3
5010 data 76,188,254,104,76,71,254,32
5011 data 181,3,32,175,3,208,248,169
5012 data 0,141,13,221,169,71,162,254
5013 data 141,24,3,142,25,3,96,174
5014 data 1,220,224,251,96,174,6,221
5015 data 228,176,144,7,228,177,240,3
5016 data 238,196,218,134,177,96,238,197
5017 data 218,162,8,142,24,212,202,208
5018 data 253,142,24,212,96,141,13,221
5019 data 141,196,218,141,197,218,238,197
5020 data 218,162,255,142,4,221,142,5
5021 data 221,232,142,7,221,134,177,166
5022 data 176,142,6,221,169,17,141,14
5023 data 221,169,81,141,15,221,96